from pydantic import BaseModel
from typing import List, Optional, Dict, Any


class SkillSchema(BaseModel):
    id: str
    name: str
    description: str


class CharacterSchema(BaseModel):
    id: str
    name: str
    nameEn: str
    avatar: Optional[str] = None
    description: Optional[str] = None
    background: Optional[str] = None
    language: List[str] = []
    personality: List[str] = []
    skills: List[SkillSchema] = []


class CharacterCreate(BaseModel):
    id: str
    name: str
    nameEn: str
    avatar: Optional[str] = None
    description: Optional[str] = None
    background: Optional[str] = None
    language: List[str] = []
    personality: List[str] = []
    skills: List[SkillSchema] = []


class CharacterUpdate(BaseModel):
    name: Optional[str] = None
    nameEn: Optional[str] = None
    avatar: Optional[str] = None
    description: Optional[str] = None
    background: Optional[str] = None
    language: Optional[List[str]] = None
    personality: Optional[List[str]] = None
    skills: Optional[List[SkillSchema]] = None


class CharacterSearchResponse(BaseModel):
    characters: List[CharacterSchema]
    total: int


class ChatRequest(BaseModel):
    message: str
    context: Optional[List[str]] = []


class ChatResponse(BaseModel):
    """聊天响应模式"""
    message: str  # 角色的回复内容
    character_id: str  # 角色ID
    character_name: str  # 角色名称
    timestamp: Optional[str] = None  # 回复时间戳
    emotion: Optional[str] = None  # 情感状态（如：开心、愤怒、思考等）
    action: Optional[str] = None  # 角色动作描述（如：微笑、皱眉、挥舞魔杖等）
    metadata: Optional[Dict[str, Any]] = {}  # 额外元数据


class ErrorResponse(BaseModel):
    error: Dict[str, str]
